package com.example.concurrentprogramming8016.disruptor.produceconsumer.singleproduce;

import com.example.concurrentprogramming8016.disruptor.produceconsumer.singleproduceconsumer.OrderEvent;
import com.lmax.disruptor.EventHandler;
import com.lmax.disruptor.WorkHandler;

/**
 * @author liyanhao
 * @Date 2023-01-08 14:21
 */
public class OrderEventHandler
        implements EventHandler<OrderEvent>,
        WorkHandler<OrderEvent> {
    @Override
    public void onEvent(OrderEvent orderEvent) throws Exception {
        //todo 消费逻辑
        System.out.println("消费者:" + Thread.currentThread().getName() +
                "name:" + orderEvent.getName() +
                "数据value" + orderEvent.getValue());
    }

    @Override
    public void onEvent(OrderEvent orderEvent, long l, boolean b) throws Exception {
        //todo 消费逻辑
        System.out.println("消费者:" + Thread.currentThread().getName() +
                "name:" + orderEvent.getName() +
                "数据value" + orderEvent.getValue());
    }
}
